package com.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dao.UserMapper;
import com.domain.User;
import com.service.UserService;

@Service
public class UserServiceImpl implements UserService{
	
	/*@Resource的作用相当于@Autowired
	 * @Autowired是spring自己定义的，@Resource是JSR-250规范定义的
	 * 推荐使用：@Resource，减少了与spring的耦合。
	 * 两者的更多区别参考：http://blog.csdn.net/gst6062825/article/details/8765157*/
	@Resource
	private UserMapper userMapper;

	@Override
	public int addUser(User user) {
		return userMapper.insert(user);
	}
	
	@Override
	public int addUsers(List<User> list) {
		for (User user : list) {
			userMapper.insert(user);
		}
		return list.size();
	}
	
	@Override
	public int updateByPrimaryKey(User user) {
		return userMapper.updateByPrimaryKey(user);
	}
	
	@Override
	public int updateByPrimaryKeySelective(User user) {
		return userMapper.updateByPrimaryKeySelective(user);
	}
	
	@Override
	public void batchUpdateByPrimaryKey(List<User> list) {
		userMapper.batchUpdateByPrimaryKey(list);
		return ;
	}
	
	@Override
	public void batchUpdateByPrimaryKeySelective(List<User> list) {
		userMapper.batchUpdateByPrimaryKeySelective(list);
		return ;
	}

	@Override
	public List<User> queryListByPaging(User user) {
		return userMapper.queryListByPaging(user);
	}

}
